<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>所有申请书查询</title>
<script type="text/javascript" src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>
</head>

<body>
	<input type="hidden" id="childDiv" class="thickbox" />
	<form method="post" id="mainForm">
			<input type="hidden" id="prpCodes" name="prpCodes" value="" />
			<input type="hidden" id="type" name="type" value="" />
		</form>

	<div class="soBox">
		<div class="detail ico_search">
			
			<table>
				<tr>
					<td rowspan="2"><strong>检索条件：</strong>
					</td>
						<security:authorize ifNotGranted="A_AUTH_DW,A_AUTH_DEPT,A_AUTH_TJBM">
					<td>
						<cpt:search key="regulatory"  repeatColumn="3" displayCount="3" leftStyle="width:80px"></cpt:search>
					</td>
					</security:authorize>		
				</tr>
				<tr>
				<td>
					<div class="clear_h10"></div>
					<input type='button' id='searchBt' class="button_an" value='查询' />
				</td>
				</tr>
			</table>
		</div>
	</div>
	<div class="clear_h10"></div>
	<div>
		<div id='TopBarMnt'></div>
		<table id='dataGrid'></table>
		<div id='dataBar'></div>
	</div>
  <iframe id="ifile" style="display:none"></iframe>
	<form action="${ctx}/prpapprove/export_excel" method="post" id="exportExcel">
		<input type="hidden" name="searchString" id="searchString" value="" />
		<input type="hidden" name="sidx" id="sortItem" value="" />
		<input type="hidden" name="sord" id="sortType" value="" />
		<input name="grantCnameKJ" type="hidden"  id="grantCnameKJ"   >
	</form>
	<%-- <form action="${ctx}/prpapprove/export_excel_collects" method="post" id="exportPrjCollects">
		<input type="hidden" name="searchString" id="searchString" value="" />
		<input type="hidden" name="sidx" id="sortItem" value="" />
		<input type="hidden" name="sord" id="sortType" value="" />
		<input name="grantCnameKJ" type="hidden"  id="grantCnameKJ"   >
	</form> --%>
	<script type="text/javascript">
	var irisGrid = new IrisGrid("dataGrid", "dataBar", 'TopBarMnt');
	var prcWin = new progressWin("${res}");//初始化遮罩层
	
	
	
	function viewComment(des3Prpcode){
		var url="${ctx}/proposal/view/audit-comment-view?posCode="+des3Prpcode+"&TB_iframe=true&height=390&width=720";
		var title="审核意见";
		showThickBox(url,title);	
	}
	
	
	
		/** 表格初始化**/
		//loadIrisGrid("${res}");
		function buildGrid() {
			var columnAttrList = new Array();
		/* 	columnAttr = new ColumnAttr("项目类别", "grant_name","grant_name", 6, "left", true);
			columnAttrList.push(columnAttr);
			 */
			columnAttr = new ColumnAttr("项目名称", "zh_title","zh_title", 6, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("操作类型", "op_type","op_type", 2, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("审核时间", "comment_date","comment_date", 2, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("审核人", "psn_name","psn_name", 5 , "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("审核意见", "AUDIT_COMMENT","AUDIT_COMMENT", 6, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
			
	/* 		<security:authorize ifNotGranted="A_AUTH_DW">
			columnAttr = new ColumnAttr("申报单位", "org_name","org_name", 7, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
			</security:authorize>
			<security:authorize ifAnyGranted="A_AUTH_JHC">
			columnAttr = new ColumnAttr("主管处室", "admin_org_name","admin_org_name", 4, "center", true);
			columnAttrList.push(columnAttr);
			</security:authorize> */
			/* <security:authorize ifAnyGranted="A_AUTH_SCS,A_AUTH_SCZJ,A_AUTH_SCZJSC,A_AUTH_SZ">
			columnAttr = new ColumnAttr("所在区市", "area_name","area_name", 3, "center", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
			</security:authorize> */
			/* columnAttr = new ColumnAttr("项目类型", "proposal_type_name","proposal_type_name", 4, "center", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr); */
			/* columnAttr = new ColumnAttr("项目负责人", "psn_name","psn_name", 5, "center", true);
			columnAttrList.push(columnAttr); */
			
			
			
	/* 		columnAttr = new ColumnAttr("专题名称", "domain_name","domain_name", 5, "center", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("水印号", "prp_version","prp_version", 6, "left", true);
			columnAttrList.push(columnAttr); */
			
		/* 	columnAttr = new ColumnAttr("受理编号", "prp_no","prp_no", 6, "left", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("技术领域", "JS_NAME","JS_NAME", 6, "left", true);
			columnAttrList.push(columnAttr); */
			
			/* columnAttr = new ColumnAttr("主管单位", "org_parent_name", "org_parent_name", 7,"center", true);
			columnAttrList.push(columnAttr); */
			/* columnAttr = new ColumnAttr("归口管理部门类型", "category", "category", 7,"center", true);
			columnAttrList.push(columnAttr);
			
			
			columnAttr = new ColumnAttr("归口管理部门", "off_name", "off_name", 7,"center", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("工作进度", "statusName", "status", 6,"center", true);
			columnAttrList.push(columnAttr); */
			/* 
			columnAttr = new ColumnAttr("审核意见", "comment", "comment", 4,"center", false,false,"text",false,1);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("PDF", "pdf", "pdf",4,"center", false,false,"text",false,1);
			columnAttrList.push(columnAttr); */
			
		//	columnAttr = new ColumnAttr("操作", "", "", 7,"center", false);
		//	columnAttrList.push(columnAttr);
			/* columnAttr = new ColumnAttr("status", "status", "status", 3,"left", false,false,"text",true,1);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("flagCan", "flagCan", "flagCan", 3,"left", false,false,"text",true,1);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("grantCode", "grantCode", "grantCode", 3,"left", false,false,"text",true,1);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("introPdfCode", "introPdfCode", "introPdfCode", 3,"left", false,false,"text",true,1); */
			irisGrid.setColumnAttrs(columnAttrList);
			
			
			irisGrid.setUrl("${ctx}/regulatoryview/list-regulatory-view");//查询url
			irisGrid.setCaption("暂写");
			irisGrid.setDefaultSortName("prp_no");//默认排序字段
			irisGrid.setDefaultSortorder("dese");
			irisGrid.setWidth(978);//整个表格宽度
			irisGrid.setCheckAble(false);//表格左边是否要复选框
			irisGrid.setShowRowIndex(true);//是否显示行号
			irisGrid.setCanExportExcel(true);
			irisGrid.setQueryBox('searchBt', <security:authorize ifNotGranted="A_AUTH_DW,A_AUTH_DEPT,,A_AUTH_TJBM">'regulatory'</security:authorize>, ["psn_name", "zh_name", "op_type"]);//查询条件 按钮名，查询条件function_key
			irisGrid.onSelectAll = function(selectid,isSelect){//全选事件
				checkSelect();
			}
			irisGrid.onSelectRow = function(selectid,isSelect){//选择事件	
				checkSelect();
			}
			irisGrid.setLoadComplete(function() {
				irisGrid.attendQuery = true;
				var searchString = irisGrid.preDealOnQuery()['searchString'];
				$("#searchString").val(searchString);
				$("#sortItem").val( irisGrid.getGridDom().jqGrid("getGridParam", 'sortname'));
				$("#sortType").val(irisGrid.getGridDom().jqGrid("getGridParam", 'sortorder'));
		        //当前显示多少条
		       	var length = $("#dataGrid").getDataIDs().length;
				if(length > 0){//当资助类别不为空且 当前页数据大于0时，显示按钮
					$("#exportPrjDetailG").show();
				} else {
					$("#exportPrjDetailG").hide();
				} 
			});
			irisGrid.build();
		}
		jQuery(function() {
			setStatus();
			buildGrid();
			//$("div[class*='ui-jqgrid-bdiv']").css("overflow","hidden");
			 $("#TopBarMnt").css("width","971px");
			 /*$("#dataGrid_toppager").css("display","none");
			$("#dataBar").css("display","none");
			$("a[class*='HeaderButton']").click(function(){
				$("#dataGrid_toppager").css("display","none");
			}); */
			$("#cb_dataGrid").click(function(){
				var checked=$(this).attr("checked");
				if(checked=="checked"){
					$("#dataGrid").find("td input[type='checkbox']").attr("checked","checked");
					$("#dataGrid").find("tr[class*='jqgrow']").each(function(){
						if($(this).find("td input[type='checkbox']").length<=0){
							$(this).removeClass("ui-state-highlight");
						}
					});
					
				}else{
					$("#dataGrid").find("td input[type='checkbox']").attr("checked",false);
				}
			});
			var index = 0;
			var stat_year = "";
			$("dl[id='stat_year']").find("a[class='c_item_checked']").each(function(){
				stat_year = $(this).prev().val();
				index ++;
			});
			if(index > 1)
				stat_year = "0";
			$("#research,#research_img,#research_tree_img").unbind("click").removeAttr("onclick");
			$("#research,#research_img,#research_tree_img").bind("click",function(){
				
				show_research("research",{"locale":"zh_CN","key":"subject_researcharea_cri","cacheable":"false","sqlParamVal":"{'grant_code':'"+$("#grantCname_hideId").val()+"','stat_year':'"+stat_year+"'}"});
			});
			$("#domain,#domain_img,#domain_tree_img").unbind("click").removeAttr("onclick");
			$("#domain,#domain_img,#domain_tree_img").bind("click",function(){
				show_domain("domain",{"locale":"zh_CN","key":"domain1","cacheable":"false","sqlParamVal":"{'grant_code':'"+$("#grantCname_hideId").val()+"','stat_year':'"+stat_year+"','researchCode':'"+$("#research_hideId").val()+"'}"});
			});

		});
		

		
		
		
		
		var getSelOpt = function() {
			var g = "";
			$("input:checkbox[id^='jqg_dataGrid_']").each(function(i, obj) {
				if (obj.checked) {
					g += "," + obj.id.replace("jqg_dataGrid_", "");
				}
			});
			if (g != "") {
				g = g.substring(1);
			}
			return g;
		};
		
		
	
		
		
		var getSelIntroPdfCode = function(){
			var flag = true;
			$("input:checkbox[id^='jqg_dataGrid_']").each(function(i,obj){
				if(obj.checked){
					var introPdfCode = $(obj).parent().parent().find("input:hidden[id^='introPdfCode_']").val();
				  if(introPdfCode == "" || introPdfCode == null){
					  flag = false;
				  }
				}
			});
			return flag;
			
		}
		
		function setStatus(){
			if('${param.prpstatus}' != ''){
				$("#prpstatus option[value='${param.prpstatus}']").attr("selected","selected");
				//$("#prpstatus option[value='1']").attr("selected", "selected"); 
			}
		}
		  function showReportKxjsjDialog(){
				 //得到页面查询条件
					var searchString=jQuery('#dataGrid').jqGrid('getGridParam','postData')['searchString'];
					if($("#grant_code").val() == '' || $("#grant_code").val()  == undefined)
					{
					 	alert("项目类别不能为空");	
					}else if($("#grant_code").val() !='916'){
						alert("请选择科学技术奖项目");	
					}else{
						//先封装数据
						//拼接查询条件的值,形如k,v;多个值之间使用[tear]隔开,当new一个PageHanlder的时候,会自动将值进行封装到ConditionContainer中
						var urlStr = "";
						var criteria_key = $("#_dyn_panel").attr("functionkey");
						var queryTableObj = $("#" + criteria_key + " *[id='_dyn_panel']");
						var querySels = [];
						$("[id^='_dyn_criteria'][id$='_field']", queryTableObj).each(
								function() {
									querySels.push($(this).attr('id'));
								});
						var querySelIdCrowd = querySels;
						
						var queryKVStr = '';
						for ( var i = 0; i < querySelIdCrowd.length; i++) {
							var selId = querySelIdCrowd[i];
							var queryId = $("#"+criteria_key).find('#' + selId).val();
							var destContral = $("#"+criteria_key).find('#' + queryId, $('#' + selId).parent().next());
							var queryValue = destContral.val();
							var fieldname = destContral.attr("name");
							var queryCellValue = $.trim(queryValue);
							if(i != querySelIdCrowd.length-1){
								urlStr = urlStr +fieldname+":"+queryCellValue+"[tear]";
							}else{
								urlStr = urlStr +fieldname+":"+queryCellValue;
							}
						}
						
					  var statYear=$("#stat_year").find("option:selected").text();
						
					  //type表示导出类型,与数据库表proposal_sl_report中的rpt_no对应,当type为空时默认设置为1,导出科学技术奖申请书信息时设置type为2
						//tb_show("导出科学技术奖项目信息清单",ctx+"/prpapprove/list-for-report1-kxjsj?searchString="+encodeURIComponent(urlStr)+"&statYear="+statYear+"&rpt_no_type=2&TB_iframe=true&height=460&width=1024", false);
					
				}
			}
		 function initSubjectTreeValueExp2(treeId, treeNode) {
				if(treeId=="grant"){
			  		$("#research").val("");
					$("#research_hideId").val("");
					$("#research_hideName").val("");
					$("#researchCname_hideId").val("");
					$("#researchCname").val("");
					$("#research_value").val("");
					$("#domain").val("");
					$("#domain_hideId").val("");
					$("#domain_hideName").val("");
					$("#domainCname_hideId").val("");
					$("#domainCname").val("");
					$("#domain_value").val("");
					$("#grant_code").val(treeNode.id);
					$("#grantCnameKJ").val(treeNode.name);
			  	}else if(treeId=="research"){
			  		$("#domain").val("");
					$("#domain_hideId").val("");
					$("#domain_hideName").val("");
					$("#domainCname_hideId").val("");
					$("#domainCname").val("");
					$("#domain_value").val("");
			  		$("#research_value").val(treeNode.id);
			  	}else if(treeId=="domain"){
			  		$("#domain_value").val(treeNode.id);
			  	}
				$("#"+treeId).parents("td").find("[name$='"+treeId+"Cname_hideId'],[id$='"+treeId+"Cname_hideId']").val(treeNode.id);
				var str = treeNode.name;
				var obj = treeNode.parentNode;
				while (obj != null) {
					str = obj.name + "-" + str;
					obj = obj.parentNode;
				}
				$("#"+treeId).parents("td").find("[name$='"+treeId+"Cname'],[id$='"+treeId+"Cname']").val(str.substring(str.indexOf("-")+1));
			}
		//覆盖函数
			function initSubjectTreeValueExp(treeId, treeNode) {
			  	if(treeId=="grant"){
			  		$("#research").val("");
					$("#research_hideId").val("");
					$("#research_hideName").val("");
					$("#researchCname_hideId").val("");
					$("#researchCname").val("");
					$("#research_value").val("");
					$("#domain").val("");
					$("#domain_hideId").val("");
					$("#domain_hideName").val("");
					$("#domainCname_hideId").val("");
					$("#domainCname").val("");
					$("#domain_value").val("");
					$("#grant_code").val(treeNode.id);
			  	}else if(treeId=="research"){
			  		$("#domain").val("");
					$("#domain_hideId").val("");
					$("#domain_hideName").val("");
					$("#domainCname_hideId").val("");
					$("#domainCname").val("");
					$("#domain_value").val("");
			  		$("#research_value").val(treeNode.id);
			  	}else if(treeId=="domain"){
			  		$("#domain_value").val(treeNode.id);
			  	}
				$("#"+treeId).parents("td").find("[name$='"+treeId+"Cname_hideId'],[id$='"+treeId+"Cname_hideId']").val(treeNode.id);
				$("#"+treeId).parents("td").find("[name$='"+treeId+"Cname'],[id$='"+treeId+"Cname']").val(treeNode.name.substring(treeNode.name.indexOf(".")+1));
			}
		 
	
	

	 
	</script>
</body>
</html>